﻿using System;
using System.Collections.Generic;
using System.Text;

class MostPopularFriend
{
    static void Main()
    {
        int size = int.Parse(Console.ReadLine());
        string[] frMatrix = new string[size];

        for (int row = 0; row < size; row++)
        {
            frMatrix[row] = Console.ReadLine();
        }
                
        int[,] checkFriend = new int[size, size];

        // Reading every friend in the list
        for (int row = 0; row < size; row++)
        {
            // Checking every symbol ('Y' or 'N')
            for (int col = 0; col < size; col++)
            {
                if (frMatrix[row][col] == 'Y')
                {
                    // Setting '1' to every cell that has 'Y', e.g. a friendship is found
                    checkFriend[row, col] = 1;

                    // Jumping to the found friend (row) to check his friends
                    for (int i = 0; i < size; i++)
                    {                        
                        if (frMatrix[col][i] == 'Y')
                        {
                            // Skip row that it is sent from
                            if (i != row)
                            {
                                checkFriend[row, i] = 1;
                            }
                        }
                    }
                }
            }
        }

        // Summing the friends
        int[] frCount = new int[size];

        for (int row = 0; row < size; row++)
        {
            for (int col = 0; col < size; col++)
            {
                frCount[row] += checkFriend[row, col];
            }
        }

        Array.Sort(frCount);

        Console.WriteLine(frCount[size - 1]);
    }
}
